#include <stdio.h>
#include <math.h>

int main()
{
    int num = 0;
    for(num = 0; num <=100000; num++)
    {
        int temp = num;
        int n = 1;
        while(temp /= 10)
        {
            n++;
        }
        int sum = 0;
        int m = num;
        while(m)
        {
            sum += pow(m % 10 , n);
            m /= 10;
        }
        if(sum == num)
        {
            printf("%d ", num);
        }
    } 
    return 0;
}